//
// Created by sht on 2025/7/4.
//
/**
 * Definition for a binary tree node.
 * struct TreeNode {
 *     int val;
 *     TreeNode *left;
 *     TreeNode *right;
 *     TreeNode() : val(0), left(nullptr), right(nullptr) {}
 *     TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
 *     TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left),
 * right(right) {}
 * };
 */
class Solution {
public:
    vector<int> inorderTraversal(TreeNode* root) {
        if(root == nullptr)
            return v;
        dfs(root);
        return v;
    }
private:
    vector<int> v;
    void dfs(TreeNode* root)
    {
        if(root->left)
            dfs(root->left);
        v.push_back(root->val);
        if(root->right)
            dfs(root->right);
    }
};